package C;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class C45 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt(),n = sc.nextInt(),m = sc.nextInt();
        System.out.println(getResult(k,n,m));
    }

    static public int getResult(int k,int n,int m) {
        System.out.println("k="+k+" n="+n+" m="+m);
        System.out.println("n>=m?="+(n>=m));
        if (n>=m) return 0;
        String price = Integer.toString(k,m);
        System.out.println("price="+price);
        Pattern p = Pattern.compile(String.valueOf(n));
        Matcher matcher = p.matcher(price);
        int count = 0;
        System.out.println("count="+count);
        while(matcher.find()) {
            count++;
            System.out.print(count+" ");
        }
        System.out.println("");
        return count;
    }
}
